package com.sumover.util;

public class ResultVo {
    private Object data;
    private Integer code;
    private String message;

    private ResultVo(Object data, String message, Integer code) {
        this.data = data;
        this.code = code;
        this.message = message;
    }

    @Override
    public String toString() {
        return "ResultVo{" +
                "data=" + data +
                ", code=" + code +
                ", message='" + message + '\'' +
                '}';
    }

    private final static Integer ERROR_CODE = -1;
    private final static Integer SUCCESS_CODE = 0;

    static public ResultVo error(String message) {
        return new ResultVo(null, message, ResultVo.ERROR_CODE);
    }

    static public ResultVo error(String message, Object data) {
        return new ResultVo(data, message, ResultVo.ERROR_CODE);
    }

    static public ResultVo success(String message, Object data) {
        return new ResultVo(data, message, ResultVo.SUCCESS_CODE);
    }


    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
